#pragma once

#include "Primitive.h"
#include <vector>

class Circle;
class ContactManifold;

class Line : public Primitive
{

	public:
		Line();
		Line(Vector p0, Vector p1);
		Line(Vector p0, Vector p1, Vector normal);
		~Line();

		void		CalculatePhysics(float dt);
		void		Update();
		void		SetPos(int i, float x, float y);
		void		SetColor(float x, float y);
		
		void		SetNormal(float x, float y);

		void		createSegments(int num, std::vector<Line>& vec);

		Vector		GetPos(int i) const;
		Vector		getNormal() { return m_normal; }
		
		void		SetPos(float x0, float y0, float x1, float y1, float nx, float ny);

		float		GetLength() const;

		virtual		Vector vectorTo(Vector p);

		void		CollisionWithCircle(Circle* circle, ContactManifold *contactManifold, float dt);

		void		CollisionResponseWithCircle(ManifoldPoint& point, float dt);
		void		CollisionResponseWithLine(ManifoldPoint& point, float dt);
		void		CollisionResponseWith(ManifoldPoint& point, float dt);

		bool		belongsInLine(Vector p);

		float		getCellX() { return cell.GetX(); }
		float		getCellY() { return cell.GetY(); }
		void		updateCell();

	private:

		void computeNormal();

		Vector cell;

		Vector m_p0;
		Vector m_p1;
		Vector m_normal;
};

